#ifndef _SOCKET_H_
#define _SOCKET_H_

#include <WinSock2.h>

class Socket {
public:
	Socket(
		OPTIONAL SOCKET _socket = NULL,
		OPTIONAL UINT _socketType = SOCK_STREAM,
		OPTIONAL sockaddr *_socketAddr = NULL );
	virtual ~Socket();
	Socket(const Socket&);
	Socket& operator=(Socket&);
	
	void Close();
	void SendBytes(IN const LPBYTE bytes,IN ULONG count);
	void ReadBytes(IN LPBYTE bytes,IN OUT ULONG &count);

protected:
	SOCKET s_;
	sockaddr *s_addr_;

	int* refCounter_;

private:
	static void Start();
	static void End();
	static int  nofSockets_;
};

#endif